package cn.iune.erp.inventory;

import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Aspect//指定这是一个其切面
public class FileItemDaoAspect {
	
	@Autowired
	private IFileItemService fileItemService;

	
	//指定切入点（增加）
    @Pointcut("execution(* cn.iune.erp.inventory.IFileItemDao.insert(..)) && args(obj)")
    public void insertPointCut(FileItem obj){}
    //指定通知以及通知的范围
    @Transactional
    @After("insertPointCut(obj)")
    public void beforeInsert(FileItem obj){
    	fileItemService.beforeInsert(obj);
    }
    
    @Transactional
    @After("insertPointCut(obj)")
    public void afterInsert(FileItem obj){
    	fileItemService.afterInsert(obj);
    }
    
	//指定切入点（删除）
    @Pointcut("execution(* cn.iune.erp.inventory.IFileItemDao.delete(..)) && args(fID)")
    public void deletePointCut(String fID){}
    //指定通知以及通知的范围
    @Transactional
    @Before("deletePointCut(fID)")
    public void beforeDelete(String fID){
    	fileItemService.beforeDelete(fID);
    }


}
